package com.uchiha.nova.mainService.wrapper;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.uchiha.nova.core.model.entity.GroupMachineRelationEntity;
import com.uchiha.nova.core.model.vo.GroupMachineRelationVO;
import com.uchiha.nova.core.tool.support.BaseEntityWrapper;
import com.uchiha.nova.core.tool.util.SpringUtil;
import com.uchiha.nova.mainService.service.IGroupMachineRelationService;

import java.util.List;
import java.util.stream.Collectors;
/**
 * 机器设备分组与机器关联 包装类,返回视图层所需的字段
 *
 * @author Uchihashiamu
 */
public class GroupMachineRelationWrapper extends BaseEntityWrapper<GroupMachineRelationEntity, GroupMachineRelationVO>  {
  
  IGroupMachineRelationService groupMachineRelationService = SpringUtil.getBean(IGroupMachineRelationService.class);
  
	public static GroupMachineRelationWrapper build() {
		return new GroupMachineRelationWrapper();
 	}

	@Override
	public GroupMachineRelationVO entityVO(GroupMachineRelationEntity groupMachineRelationEntity) {
		GroupMachineRelationVO groupMachineRelationVO = new GroupMachineRelationVO();
		BeanUtil.copyProperties(groupMachineRelationEntity, groupMachineRelationVO);

		return groupMachineRelationVO;
	}
	public List<GroupMachineRelationVO> listVO(List<GroupMachineRelationEntity> list) {
		List<GroupMachineRelationVO> collect = list.stream().map(item -> {
            GroupMachineRelationVO groupMachineRelationVO = new GroupMachineRelationVO();
		    BeanUtil.copyProperties(item, groupMachineRelationVO);			
			return groupMachineRelationVO;
		}).collect(Collectors.toList());
		return collect;
    // return ForestNodeMerger.merge(collect);
	}
  
  	@Override
	public IPage<GroupMachineRelationVO> pageVO(IPage<GroupMachineRelationEntity> pages) {
		IPage<GroupMachineRelationVO> page = pages.convert(item->{
            GroupMachineRelationVO groupMachineRelationVO = new GroupMachineRelationVO();
		    BeanUtil.copyProperties(item, groupMachineRelationVO);			
			return groupMachineRelationVO;
		});
		return page;
	}
}
